package ch.fhnw.qualiscan.core;

import ch.fhnw.qualiscan.AppObject;
import ch.fhnw.qualiscan.core.helpers.SessionHelper;
import ch.fhnw.qualiscan.core.helpers.TextHelper;
import ch.fhnw.qualiscan.core.libraries.ComponentLib;
import ch.fhnw.qualiscan.core.libraries.ModalLib;
import ch.fhnw.qualiscan.core.libraries.UrlLib;

import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;

import eu.livotov.tpt.TPTApplication;

/**
* Abstract class for all components. All components need to inherit from this class.
* @author Kevin Mettenberger, Benjamin Groehbiel
*
*/

@SuppressWarnings("serial")
public abstract class LayoutComponent extends VerticalLayout {
	
	public TextHelper textHelper;
	public SessionHelper sessionHelper;
	public ComponentLib componentLib;
	public UrlLib urlLib;
	public AppObject dataObject;
	public ModalLib modalLib;
	
	/**
	 * Constructor; loading all necessary functions for the concrete component.
	 */
	public LayoutComponent() {
		setStyleName("component");
		setSpacing(true);
		textHelper = new TextHelper();
		sessionHelper = new SessionHelper();
		componentLib = new ComponentLib();
		dataObject = (AppObject) TPTApplication.getCurrentApplication().getMainWindow().getData();
		urlLib = dataObject.getUrlLib();
		modalLib = new ModalLib();
		
		buildComponent();
	}

	/**
	 * open a modal box.
	 * @param modal the window you would like to load.
	 */
	public void openModal(Window modal) {
		modalLib.openModal(modal);
	}
	
	/**
	 * Layout implementation with ui elements.
	 */
	public abstract void buildComponent();
	
}
